library Wave14e initializer init requires LegacySystem, LostCauseMAIN, ContainmentMAIN, MagnificentBastardsMAIN

	private function Chapter2Climax takes nothing returns nothing
        call FogTransition(0.03)
        call GankMarine(Player(13),'n004',2+udg_Spawn,1600,2000)
        call PolledWait(5.)
        call FogTransition(0.05)
        call RandomSpawn('u00L',4,IMinBJ(5, udg_Players)) //Blink
        call GankMarine(Player(14),'n002',udg_Spawn,1600,2000)
        call GankMarine(Player(13),'n004',udg_Spawn,1600,2000)
        if udg_Players>=6 then
            call RandomSpawn('ugar',1,2)
            call RandomSpawn('n002',1,2)
        endif
        call PolledWait(5.)
        call RandomSpawn('ugar',1,GetRandomInt(1,udg_Spawn)) //Gargoyle
        call GankMarine(Player(13),'n004',2+udg_Spawn,1600,2000)
    endfunction
	
    private function Wave14e takes nothing returns nothing
        local integer i=1
        set udg_CurrentWave = 14
        call GenericActions.execute()
        call SetProximitySpawnEnabled(false)
        call RandomSpawn('z00C',2,GetRandomInt(0,3)) //Assasin
        call PolledWait(120.*udg_Pace)
        call RandomSpawn('z00C',2,GetRandomInt(0,1)) //Assasin
        call SetForceAllianceStateBJ(bj_FORCE_PLAYER[9],udg_UnknownEntities,bj_ALLIANCE_UNALLIED)
        call SetForceAllianceStateBJ(udg_UnknownEntities,bj_FORCE_PLAYER[9],bj_ALLIANCE_UNALLIED)
        loop
            exitwhen i>6
            if GetWidgetLife(udg_Spotlight[i])>0.405 then
                call KillUnit(udg_Spotlight[i])
            endif
            set i=i+1
        endloop
        set i=1
        loop
            exitwhen i>8
            if GetWidgetLife(udg_Boss2[i])>0.405 then
                call RemoveUnit(udg_Boss2[i])
            endif
            set i=i+1
        endloop
        call GeneralText(3.0, "|cffcd950cMarine|r : All the Class As have gone. We're safe for now." )
        call PolledWait(30.0*udg_Pace)
        call FieldChat(udg_Hero[udg_Sorted[GetRandomInt(1,udg_Players)]],5.0,"|cffcd950cMarine|r : The clouds are clearing!")
        call SetImmortalSpawnEnabled(false)
        call SetCrepitusSpawnEnabled(false)
        call SetGhoulSpawnEnabled(false)
        call LightningAmbience.execute()
        call PolledWait(4.5)
        call LightningAmbience.execute()
        call PolledWait(1.2)
        call SetDayNightModels( "Environment\\DNC\\DNCAshenvale\\DNCAshenvaleTerrain\\DNCAshenvaleTerrain.mdl", "Environment\\DNC\\DNCAshenvale\\DNCAshenvaleUnit\\DNCAshenvaleUnit.mdl" )
        call Chapter2Climax.execute()
        call PolledWait(35.0*udg_Pace)

        if udg_SquadXP>45000 and GetRandomInt(0,1)==1 and (udg_Players>2 or udg_SquadXP>100000) then
            call LostCauseMAIN()
        elseif GetRandomInt(0,2)!=1 then
            call MagnificentBastardsMAIN()
        else
            call ContainmentMAIN()
        endif
    endfunction

    private function init takes nothing returns nothing
        call RegisterFunction("Wave14e", function Wave14e)
        // call ExecuteRegisteredFunction("Wave14e")
    endfunction

endlibrary

